/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.testes;

import br.com.beans.Cliente;
import br.com.beans.ComparadorClienteQtdPedidos;
import br.com.beans.ComparadorClientesId;
import java.util.Iterator;
import java.util.Set;
import java.util.TreeSet;

/**
 *
 * @author egberto
 */
public class TesteComparator {

    public static void main(String args[]){
        
        Cliente cl1 = new Cliente(1, "Cliente 01", 205);
        Cliente cl2 = new Cliente(2, "Globalcode", 43);
        Cliente cl3 = new Cliente(3, "Cliente 02", 89);
        Cliente cl4 = new Cliente(1, "Cliente 03", 20);
        
        
        ComparadorClienteQtdPedidos comp = new ComparadorClienteQtdPedidos();
        Set ts = new TreeSet(comp);
        ts.add(cl1);
        ts.add(cl2);
        ts.add(cl3);
        ts.add(cl4);
        
        Iterator iterator = ts.iterator();
        System.out.println("\nUtilizando ComparadorClientesQtdPedidos");
        while(iterator.hasNext()){
            System.out.println(iterator.next());
        }
        
        ComparadorClientesId compId = new ComparadorClientesId();
        Set ts2 = new TreeSet(compId);
        ts2.addAll(ts);
        
        Iterator it2 = ts2.iterator();
        System.out.println("\nUtilizando ComparadorClientesId");
        while(it2.hasNext()){
            System.out.println(it2.next());
        }
        
    }
}
